<%@ Page Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="System.Web.Mvc.ViewPage<Animoso.Domain.NewsItem>" %>
<%@ Import Namespace="Animoso.Web.Controllers" %>

<asp:Content ID="Head" ContentPlaceHolderID="HeadPlaceHolder" runat="server">
    <link href="../../uploadify/uploadify.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(document).ready(function() {
        $('#upload').uploadify({
            'uploader': '/uploadify/uploadify.swf',
            'cancelImg': '/uploadify/cancel.png',
            'script': '/News/Upload',
            'onComplete': handleResponse,
            'scriptData': { newsItemId: '<%=Model.Id %>' }
        });
    });

    function handleResponse(vent, queueID, fileObj, response, data) {                
        $('#fotoPreview').attr('src', '/Upload/Pictures/' + response.toString());
    }
</script>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Animoso: Nieuws Toevoegen
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%= Html.ValidationSummary("NewsItem Toevoegen mislukt, herstel de fouten en probeer het nogmaals.") %>

    <% using (Html.BeginForm("Publish", "News", FormMethod.Post)) {%>

        <fieldset>
            <legend>NieuwsItem</legend>
            <p>
                <label for="Title">Titel:</label><br />
                <%=Html.TextBox("Title", Model.Title) %>
                <%= Html.ValidationMessage("Title", "*") %>
            </p>
            <p>
                <label for="Picture">Foto:</label><br />
                <input type="file" name="upload" id="upload" />
                <%=Html.ValidationMessage("Picture", "*") %>   
                <a href="javascript:$('#upload').uploadifyUpload();">Upload</a>            
                <% if (!string.IsNullOrEmpty(Model.Picture))
{%>
                    <img id="fotoPreview" src="/Upload/<%=Folders.NEWS_PICTURE_FOLDER + "/" + Model.Picture%>" />
                    <%
}
                   else
                   {
           %>
           <img id="fotoPreview" />
           <% } %>
            </p>
            
            <p>
                <label for="Text">Text:</label><br />
                <%= Html.TextArea("Text", Model.Text, 15, 50,null) %>
                <%= Html.ValidationMessage("Text", "*") %>
            </p>
            <p>
                <%=Html.Hidden("Id", Model.Id) %>
                <input type="submit" id="submit" value="Publiceer" class="wymupdate" />
            </p>
        </fieldset>

    <% } %>

    <div>
        <%=Html.ActionLink("Terug", "Index") %>
    </div>
    <script type="text/javascript">

        jQuery(function() {
            jQuery("#Text").wymeditor();
        });
</script>
</asp:Content>

